home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 June / EnigmA AMIGA RUN 08 (1996)(G.R. Edizioni)(IT)[!][issue 1996-06][EARSAN CD VII].iso / earcd / utmisc1 / mprz2v10.lha / MapRZ2_EVD1_0 / Source / RetinaZ2mapped.asm < prev    next >
Assembly Source File  |  1996-03-27  |  7KB  |  371 lines

  1. *
  2. * ShapeShifter external video driver for Retina Z2
  3. *
  4. * $VER: RetinaZ2mapped.asm 1.0 (30.12.95)
  5. *
  6. * Christoph Niedeggen 24.12.95-30.12.95
  7. * based on code by Christian Bauer
  8.  
  9.         MACHINE    68020
  10.  
  11.         INCLUDE    "exec/types.i"
  12.         INCLUDE    "exec/macros.i"
  13.         INCLUDE    "exec/memory.i"
  14.         INCLUDE    "intuition/intuition.i"
  15.         INCLUDE    "utility/tagitem.i"
  16.         INCLUDE    "exec/alerts.i"
  17.         INCLUDE    "libraries/retina.i"
  18.         INCLUDE    "libraries/retina_lib.i"
  19.         INCLUDE    "shapeextvideo.i"
  20.  
  21. *
  22. * Offset for linear mapped RetinaZ2 RAM
  23. *
  24.  
  25. C_RL_START    equ    $01c00000
  26.  
  27. *
  28. * Definition of our private context structure for storing local variables
  29. *
  30.  
  31.  STRUCTURE    MyContext,0
  32.     APTR    conIntuitionBase
  33.     APTR    conRetinaBase
  34.  
  35.     APTR    conScreen    ;The screen
  36.     APTR    conRetinaScr    ;The screen's RetinaScreen
  37.  
  38.     STRUCT    conRGBBuf,256*3    ;Buffer for LoadRGB32
  39.  
  40.     WORD    conVideoMode    ;Video mode (VMODE_*)
  41.  LABEL    MyContext_SIZEOF
  42.  
  43. *
  44. * This is the driver header
  45. *
  46.  
  47.         EVHEADER DriverTags
  48.  
  49. *
  50. * The header tags that describe the driver and provide pointers to
  51. * the driver's routines
  52. *
  53.  
  54. DriverTags    dc.l    SHEV_Level,1        ;Interface level 1
  55.         dc.l    SHEV_Version,0
  56.         dc.l    SHEV_Revision,1
  57.         dc.l    SHEV_Name,DriverName
  58.         dc.l    SHEV_ID,DriverID
  59.         dc.l    SHEV_Author,DriverAuthor
  60.  
  61.         dc.l    SHEV_OpenScreen,MyOpenScreen
  62.         dc.l    SHEV_CloseScreen,MyCloseScreen
  63.         dc.l    SHEV_LoadRGB32,MyLoadRGB32
  64.         dc.l    SHEV_Refresh,MyRefresh
  65.         dc.l    TAG_END,0
  66.  
  67. DriverName    dc.b    "Retina Z2 mapped Driver",0
  68.         CNOP    0,4
  69. DriverID    dc.b    "$VER: RetinaZ2mapped 1.0 (30.12.95)",13,10,0
  70.         CNOP    0,4
  71. DriverAuthor    dc.b    "Christoph Niedeggen",0
  72.         CNOP    0,4
  73.  
  74. *
  75. * The OpenScreen routine
  76. * a0: Taglist with input parameters
  77. * a1: Taglist with output parameters
  78. * a6: Base of utility.library
  79. *
  80.  
  81. MyOpenScreen    movem.l    d2-d7/a2-a6,-(sp)
  82.         move.l    a0,a4            ;a4: Input taglist
  83.         move.l    a1,a5            ;a5: Output taglist
  84.         move.l    a6,_UtilityBase
  85.         move.l    (4).w,_ExecBase
  86.  
  87. ; Allocate memory for context
  88.         move.l    _ExecBase,a6
  89.         move.l    #MyContext_SIZEOF,d0
  90.         move.l    #MEMF_PUBLIC|MEMF_CLEAR,d1
  91.         JSRLIB    AllocVec
  92.         tst.l    d0
  93.         beq    OpenFailed
  94.         move.l    d0,a2            ;a2: Context
  95.  
  96. ; Open intuition.library
  97.         move.l    _ExecBase,a6
  98.         lea    IntuitionName,a1
  99.         moveq    #37,d0
  100.         JSRLIB    OpenLibrary
  101.         move.l    d0,conIntuitionBase(a2)
  102.         beq    OpenFailed
  103.  
  104. ; Open retina.library
  105.         move.l    _ExecBase,a6
  106.         lea    RetinaName,a1
  107.         moveq    #0,d0
  108.         JSRLIB    OpenLibrary
  109.         move.l    d0,conRetinaBase(a2)
  110.         beq    OpenFailed
  111.  
  112. ; Store context pointer in output taglist
  113.         move.l    _UtilityBase,a6
  114.         move.l    a5,a0
  115.         move.l    #SHEV_Context,d0
  116.         JSRLIB    FindTagItem
  117.         move.l    d0,a0
  118.         move.l    a2,ti_Data(a0)
  119.  
  120. ; Get video mode and set the refresh type and screen depth accordingly
  121. ; This driver only supports VMODE_8BIT
  122.         move.l    _UtilityBase,a6
  123.         move.l    a4,a0
  124.         move.l    #SHEV_VideoMode,d0
  125.         moveq    #VMODE_1BIT,d1        ;Dummy default
  126.         JSRLIB    GetTagData
  127.         move.w    d0,conVideoMode(a2)
  128.  
  129.         cmp.l    #VMODE_8BIT,d0
  130.         bne    OpenFailed
  131.         move.l    a5,a0
  132.         move.l    #SHEV_RefreshType,d0
  133.         JSRLIB    FindTagItem
  134.         tst.l    d0
  135.         beq    10$
  136.         move.l    d0,a1
  137.         move.l    #RTYPE_CUSTOM,ti_Data(a1)    ;to get Vector at $8 patched
  138. 10$
  139.  
  140. ; Extract screen parameters from input taglist
  141.         move.l    _UtilityBase,a6
  142.         move.l    a4,a0
  143.         move.l    #SHEV_ScreenX,d0
  144.         moveq    #0,d1
  145.         JSRLIB    GetTagData
  146.         move.l    d0,ScrWidth
  147.  
  148.         move.l    a4,a0
  149.         move.l    #SHEV_ScreenY,d0
  150.         moveq    #0,d1
  151.         JSRLIB    GetTagData
  152.         move.l    d0,ScrHeight
  153.  
  154. ; Open the screen and store pointer in output taglist
  155.  
  156.         move.l    ScrWidth,d0
  157.         move.l    ScrHeight,d1
  158.         moveq    #0,d2                ;ID: has to be selected with RetinaPrefs
  159.         moveq    #0,d3
  160.         sub.l    a0,a0
  161.         move.l    conRetinaBase(a2),a6
  162.         jsr    _LVORetina_OpenScreen(a6)
  163.         move.l    d0,conRetinaScr(a2)
  164.         beq    OpenFailed
  165.  
  166.         move.l    conIntuitionBase(a2),a6
  167.         sub.l    a0,a0
  168.         lea    ScreenTags,a1
  169.         JSRLIB    OpenScreenTagList
  170.         move.l    d0,a3            ;a3: Screen
  171.         move.l    d0,conScreen(a2)
  172.         beq    OpenFailed
  173.         bra    ScreenOpened
  174.  
  175. ScreenOpened    move.l    _UtilityBase,a6
  176.         move.l    a5,a0
  177.         move.l    #SHEV_Screen,d0
  178.         JSRLIB    FindTagItem
  179.         move.l    d0,a0
  180.         move.l    a3,ti_Data(a0)
  181.  
  182. ; Extract all the other data that the caller wants
  183.         move.l    _UtilityBase,a6
  184.         move.l    a5,a0
  185.         move.l    #SHEV_ScreenBase,d0
  186.         JSRLIB    FindTagItem
  187.         tst.l    d0
  188.         beq    1$
  189.         move.l    d0,a1
  190.         move.l    conRetinaScr(a2),a0
  191.         move.l    _rs_BitMap(a0),a0
  192.         move.l    a0,d0
  193.         add.l    #C_RL_START,d0            ;CN24.12.95
  194.         move.l    d0,ti_Data(a1)
  195. 1$
  196.         move.l    _UtilityBase,a6
  197.         move.l    a5,a0
  198.         move.l    #SHEV_BytesPerRow,d0
  199.         JSRLIB    FindTagItem
  200.         tst.l    d0
  201.         beq    2$
  202.         move.l    d0,a1
  203.         move.l    conRetinaScr(a2),a0
  204.         moveq    #0,d0
  205.         move.w    _rs_Modulo(a0),d0
  206.         move.l    d0,ti_Data(a1)
  207. 2$
  208.  
  209. ; Everything is OK
  210.         movem.l    (sp)+,d2-d7/a2-a6
  211.         moveq    #0,d0
  212.         rts
  213.  
  214. ; An error occurred
  215. OpenFailed    movem.l    (sp)+,d2-d7/a2-a6
  216.         moveq    #-1,d0
  217.         rts
  218.  
  219. *
  220. * The CloseScreen routine
  221. * a0: Taglist with input parameters
  222. * a1: Taglist with output parameters
  223. * a2: Context pointer (never NULL)
  224. * a6: Base of utility.library
  225. *
  226.  
  227. MyCloseScreen    movem.l    d2-d7/a2-a6,-(sp)
  228.  
  229. ; Close the screen
  230.         move.l    conScreen(a2),d0
  231.         beq    1$
  232.         move.l    d0,a0
  233.         move.l    conIntuitionBase(a2),a6
  234.         JSRLIB    CloseScreen
  235. 1$
  236.         move.l    conRetinaScr(a2),d0
  237.         beq    2$
  238.         move.l    d0,a0
  239.         move.l    conRetinaBase(a2),a6
  240.         jsr    _LVORetina_CloseScreen(a6)
  241. 2$
  242.  
  243. ; Close retina.library
  244.         move.l    conRetinaBase(a2),d0
  245.         beq    3$
  246.         move.l    d0,a1
  247.         move.l    _ExecBase,a6
  248.         JSRLIB    CloseLibrary
  249. 3$
  250.  
  251. ; Close intuition.library
  252.         move.l    conIntuitionBase(a2),d0
  253.         beq    6$
  254.         move.l    d0,a1
  255.         move.l    _ExecBase,a6
  256.         JSRLIB    CloseLibrary
  257. 6$
  258.  
  259. ; Free context
  260.         move.l    _ExecBase,a6
  261.         move.l    a2,a1
  262.         JSRLIB    FreeVec
  263.  
  264. CloseDone    movem.l    (sp)+,d2-d7/a2-a6
  265.         moveq    #0,d0
  266.         rts
  267.  
  268. *
  269. * The LoadRGB32 routine
  270. * a0: Taglist with input parameters
  271. * a1: Taglist with output parameters
  272. * a2: Context pointer
  273. * a6: Base of utility.library
  274. *
  275.  
  276. ; Get pointer to 32 bit color table
  277. MyLoadRGB32    movem.l    d2-d7/a2-a6,-(sp)
  278.         move.l    a0,a4        ;a4: Input taglist
  279.         move.l    #SHEV_ColorTable,d0
  280.         moveq    #0,d1
  281.         JSRLIB    GetTagData
  282.         move.l    d0,a0        ;a0: Color table
  283.  
  284. ; Convert to 8 bit color table
  285.         lea    conRGBBuf(a2),a1
  286.         move.w    #256*3-1,d1
  287. 1$        move.l    (a0)+,d0
  288.         rol.l    #8,d0
  289.         move.b    d0,(a1)+
  290.         dbra    d1,1$
  291.  
  292. ; Activate palette
  293.         move.l    conRetinaBase(a2),a6
  294.         move.l    conRetinaScr(a2),a0
  295.         moveq    #0,d0        ;Start with color #0
  296.         move.l    #256,d1        ;Load 256 colors
  297.         lea    conRGBBuf(a2),a1
  298.         jsr    _LVORetina_LoadPalette(a6)
  299.  
  300.         movem.l    (sp)+,d2-d7/a2-a6
  301.         moveq    #0,d0
  302.         rts
  303.  
  304.  
  305. MyRefresh    movem.l    a5-a6,-(sp)
  306.  
  307.         move.l    (4).w,a6
  308.         lea    setVBR(pc),a5
  309.         jsr    -$001e(a6)            ;Supervisor()
  310.  
  311.         movem.l    (sp)+,a5-a6
  312.         rts
  313.  
  314. setVBR        movec.l    VBR,a0
  315.         move.l    $8(a0),$8
  316.         rte
  317.  
  318. *
  319. * Constants
  320. *
  321.  
  322. ; Library names
  323. IntuitionName    dc.b    "intuition.library",0
  324. GfxName        dc.b    "graphics.library",0
  325. DOSName        dc.b    "dos.library",0
  326. RetinaName    dc.b    "retina.library",0
  327. RetinaEmuName    dc.b    "retinaemu.library",0
  328.  
  329. ; The name of our screen
  330. ScreenName    dc.b    "ShapeShifter Screen",0
  331.         CNOP    0,4
  332.  
  333. *
  334. * Data section
  335. *
  336.  
  337.         SECTION    "DATA",DATA
  338.  
  339. ; Taglist for OpenScreen()
  340. ; Note that it's only safe to use this structure here because
  341. ;  the SHEV_OpenScreen routine is guaranteed not to be called
  342. ;  more than once at a time. The buffer for LoadRGB32, however,
  343. ;  is declared in the Context and not in the BSS segment because
  344. ;  that routine may be called multiple times for multiple
  345. ;  screens.
  346. ScreenTags    dc.l    SA_Depth            ;screen with 16x16 pixels, 1 bit
  347.         dc.l    1                ;(just to provide intuition screen for input)
  348.         dc.l    SA_Width
  349.         dc.l    16
  350.         dc.l    SA_Height
  351.         dc.l    16
  352.         dc.l    SA_Quiet,-1
  353.         dc.l    SA_Title,ScreenName
  354.         dc.l    TAG_END,0
  355.  
  356. ;values for Retina screen
  357. ScrWidth    dc.l    0
  358. ScrHeight    dc.l    0
  359.  
  360. *
  361. * BSS section
  362. *
  363.  
  364.         SECTION    "BSS",BSS
  365.  
  366. ; Library base pointers
  367. _ExecBase    ds.l    1
  368. _UtilityBase    ds.l    1
  369.  
  370.         END
  371.